part of 'widgets.dart';

/// [VanRoot]属性常量
const kVanBlack = VanCssKey._raw('--van-black');
const kVanWhite = VanCssKey._raw('--van-white');
const kVanGray1 = VanCssKey._raw('--van-gray-1');
const kVanGray2 = VanCssKey._raw('--van-gray-2');
const kVanGray3 = VanCssKey._raw('--van-gray-3');
const kVanGray4 = VanCssKey._raw('--van-gray-4');
const kVanGray5 = VanCssKey._raw('--van-gray-5');
const kVanGray6 = VanCssKey._raw('--van-gray-6');
const kVanGray7 = VanCssKey._raw('--van-gray-7');
const kVanGray8 = VanCssKey._raw('--van-gray-8');
const kVanRed = VanCssKey._raw('--van-red');
const kVanBlue = VanCssKey._raw('--van-blue');
const kVanOrange = VanCssKey._raw('--van-orange');
const kVanOrangeDark = VanCssKey._raw('--van-orange-dark');
const kVanOrangeLight = VanCssKey._raw('--van-orange-light');
const kVanGreen = VanCssKey._raw('--van-green');
const kVanGradientRed = VanCssKey._raw('--van-gradient-red');
const kVanGradientOrange = VanCssKey._raw('--van-gradient-orange');
const kVanPrimaryColor = VanCssKey._raw('--van-primary-color');
const kVanSuccessColor = VanCssKey._raw('--van-success-color');
const kVanDangerColor = VanCssKey._raw('--van-danger-color');
const kVanWarningColor = VanCssKey._raw('--van-warning-color');
const kVanTextColor = VanCssKey._raw('--van-text-color');
const kVanTextColor2 = VanCssKey._raw('--van-text-color-2');
const kVanTextColor3 = VanCssKey._raw('--van-text-color-3');
const kVanActiveColor = VanCssKey._raw('--van-active-color');
const kVanActiveOpacity = VanCssKey._raw('--van-active-opacity');
const kVanDisabledOpacity = VanCssKey._raw('--van-disabled-opacity');
const kVanBackground = VanCssKey._raw('--van-background');
const kVanBackground2 = VanCssKey._raw('--van-background-2');
const kVanBackground3 = VanCssKey._raw('--van-background-3');
const kVanPaddingBase = VanCssKey._raw('--van-padding-base');
const kVanPaddingXs = VanCssKey._raw('--van-padding-xs');
const kVanPaddingSm = VanCssKey._raw('--van-padding-sm');
const kVanPaddingMd = VanCssKey._raw('--van-padding-md');
const kVanPaddingLg = VanCssKey._raw('--van-padding-lg');
const kVanPaddingXl = VanCssKey._raw('--van-padding-xl');
const kVanFontBold = VanCssKey._raw('--van-font-bold');
const kVanFontSizeXs = VanCssKey._raw('--van-font-size-xs');
const kVanFontSizeSm = VanCssKey._raw('--van-font-size-sm');
const kVanFontSizeMd = VanCssKey._raw('--van-font-size-md');
const kVanFontSizeLg = VanCssKey._raw('--van-font-size-lg');
const kVanLineHeightXs = VanCssKey._raw('--van-line-height-xs');
const kVanLineHeightSm = VanCssKey._raw('--van-line-height-sm');
const kVanLineHeightMd = VanCssKey._raw('--van-line-height-md');
const kVanLineHeightLg = VanCssKey._raw('--van-line-height-lg');
const kVanBaseFont = VanCssKey._raw('--van-base-font');
const kVanPriceFont = VanCssKey._raw('--van-price-font');
const kVanDurationBase = VanCssKey._raw('--van-duration-base');
const kVanDurationFast = VanCssKey._raw('--van-duration-fast');
const kVanEaseOut = VanCssKey._raw('--van-ease-out');
const kVanEaseIn = VanCssKey._raw('--van-ease-in');
const kVanBorderColor = VanCssKey._raw('--van-border-color');
const kVanBorderWidth = VanCssKey._raw('--van-border-width');
const kVanRadiusSm = VanCssKey._raw('--van-radius-sm');
const kVanRadiusMd = VanCssKey._raw('--van-radius-md');
const kVanRadiusLg = VanCssKey._raw('--van-radius-lg');
const kVanRadiusMax = VanCssKey._raw('--van-radius-max');

@immutable
class VanRootThemeData with VanProvide {
  final VanCss<Color> black;
  final VanCss<Color> white;
  final VanCss<Color> gray1;
  final VanCss<Color> gray2;
  final VanCss<Color> gray3;
  final VanCss<Color> gray4;
  final VanCss<Color> gray5;
  final VanCss<Color> gray6;
  final VanCss<Color> gray7;
  final VanCss<Color> gray8;
  final VanCss<Color> red;
  final VanCss<Color> blue;
  final VanCss<Color> orange;
  final VanCss<Color> orangeDark;
  final VanCss<Color> orangeLight;
  final VanCss<Color> green;
  final VanCss<Gradient> gradientRed;
  final VanCss<Gradient> gradientOrange;
  final VanCss<Color> primaryColor;
  final VanCss<Color> successColor;
  final VanCss<Color> dangerColor;
  final VanCss<Color> warningColor;
  final VanCss<Color> textColor;
  final VanCss<Color> textColor2;
  final VanCss<Color> textColor3;
  final VanCss<Color> activeColor;
  final VanCss<double> activeOpacity;
  final VanCss<double> disabledOpacity;
  final VanCss<VanBgColor> background;
  final VanCss<VanBgColor> background2;
  final VanCss<VanBgColor> background3;
  final VanCss<double> paddingBase;
  final VanCss<double> paddingXs;
  final VanCss<double> paddingSm;
  final VanCss<double> paddingMd;
  final VanCss<double> paddingLg;
  final VanCss<double> paddingXl;
  final VanCss<double> fontBold;
  final VanCss<double> fontSizeXs;
  final VanCss<double> fontSizeSm;
  final VanCss<double> fontSizeMd;
  final VanCss<double> fontSizeLg;
  final VanCss<double> lineHeightXs;
  final VanCss<double> lineHeightSm;
  final VanCss<double> lineHeightMd;
  final VanCss<double> lineHeightLg;
  final VanCss<String> baseFont;
  final VanCss<String> priceFont;
  final VanCss<double> durationBase;
  final VanCss<double> durationFast;
  final VanCss<String> easeOut;
  final VanCss<String> easeIn;
  final VanCss<Color> borderColor;
  final VanCss<double> borderWidth;
  final VanCss<double> radiusSm;
  final VanCss<double> radiusMd;
  final VanCss<double> radiusLg;
  final VanCss<double> radiusMax;

  const VanRootThemeData.raw(
      {required this.black,
      required this.white,
      required this.gray1,
      required this.gray2,
      required this.gray3,
      required this.gray4,
      required this.gray5,
      required this.gray6,
      required this.gray7,
      required this.gray8,
      required this.red,
      required this.blue,
      required this.orange,
      required this.orangeDark,
      required this.orangeLight,
      required this.green,
      required this.gradientRed,
      required this.gradientOrange,
      required this.primaryColor,
      required this.successColor,
      required this.dangerColor,
      required this.warningColor,
      required this.textColor,
      required this.textColor2,
      required this.textColor3,
      required this.activeColor,
      required this.activeOpacity,
      required this.disabledOpacity,
      required this.background,
      required this.background2,
      required this.background3,
      required this.paddingBase,
      required this.paddingXs,
      required this.paddingSm,
      required this.paddingMd,
      required this.paddingLg,
      required this.paddingXl,
      required this.fontBold,
      required this.fontSizeXs,
      required this.fontSizeSm,
      required this.fontSizeMd,
      required this.fontSizeLg,
      required this.lineHeightXs,
      required this.lineHeightSm,
      required this.lineHeightMd,
      required this.lineHeightLg,
      required this.baseFont,
      required this.priceFont,
      required this.durationBase,
      required this.durationFast,
      required this.easeOut,
      required this.easeIn,
      required this.borderColor,
      required this.borderWidth,
      required this.radiusSm,
      required this.radiusMd,
      required this.radiusLg,
      required this.radiusMax});

  /// 拷贝
  VanRootThemeData copyFrom({
    VanCss<Color>? black,
    VanCss<Color>? white,
    VanCss<Color>? gray1,
    VanCss<Color>? gray2,
    VanCss<Color>? gray3,
    VanCss<Color>? gray4,
    VanCss<Color>? gray5,
    VanCss<Color>? gray6,
    VanCss<Color>? gray7,
    VanCss<Color>? gray8,
    VanCss<Color>? red,
    VanCss<Color>? blue,
    VanCss<Color>? orange,
    VanCss<Color>? orangeDark,
    VanCss<Color>? orangeLight,
    VanCss<Color>? green,
    VanCss<Gradient>? gradientRed,
    VanCss<Gradient>? gradientOrange,
    VanCss<Color>? primaryColor,
    VanCss<Color>? successColor,
    VanCss<Color>? dangerColor,
    VanCss<Color>? warningColor,
    VanCss<Color>? textColor,
    VanCss<Color>? textColor2,
    VanCss<Color>? textColor3,
    VanCss<Color>? activeColor,
    VanCss<double>? activeOpacity,
    VanCss<double>? disabledOpacity,
    VanCss<VanBgColor>? background,
    VanCss<VanBgColor>? background2,
    VanCss<VanBgColor>? background3,
    VanCss<double>? paddingBase,
    VanCss<double>? paddingXs,
    VanCss<double>? paddingSm,
    VanCss<double>? paddingMd,
    VanCss<double>? paddingLg,
    VanCss<double>? paddingXl,
    VanCss<double>? fontBold,
    VanCss<double>? fontSizeXs,
    VanCss<double>? fontSizeSm,
    VanCss<double>? fontSizeMd,
    VanCss<double>? fontSizeLg,
    VanCss<double>? lineHeightXs,
    VanCss<double>? lineHeightSm,
    VanCss<double>? lineHeightMd,
    VanCss<double>? lineHeightLg,
    VanCss<String>? baseFont,
    VanCss<String>? priceFont,
    VanCss<double>? durationBase,
    VanCss<double>? durationFast,
    VanCss<String>? easeOut,
    VanCss<String>? easeIn,
    VanCss<Color>? borderColor,
    VanCss<double>? borderWidth,
    VanCss<double>? radiusSm,
    VanCss<double>? radiusMd,
    VanCss<double>? radiusLg,
    VanCss<double>? radiusMax
  }) {
    return VanRootThemeData.raw(
      black: black ?? this.black,
      white: white ?? this.white,
      gray1: gray1 ?? this.gray1,
      gray2: gray2 ?? this.gray2,
      gray3: gray3 ?? this.gray3,
      gray4: gray4 ?? this.gray4,
      gray5: gray5 ?? this.gray5,
      gray6: gray6 ?? this.gray6,
      gray7: gray7 ?? this.gray7,
      gray8: gray8 ?? this.gray8,
      red: red ?? this.red,
      blue: blue ?? this.blue,
      orange: orange ?? this.orange,
      orangeDark: orangeDark ?? this.orangeDark,
      orangeLight: orangeLight ?? this.orangeLight,
      green: green ?? this.green,
      gradientRed: gradientRed ?? this.gradientRed,
      gradientOrange: gradientOrange ?? this.gradientOrange,
      primaryColor: primaryColor ?? this.primaryColor,
      successColor: successColor ?? this.successColor,
      dangerColor: dangerColor ?? this.dangerColor,
      warningColor: warningColor ?? this.warningColor,
      textColor: textColor ?? this.textColor,
      textColor2: textColor2 ?? this.textColor2,
      textColor3: textColor3 ?? this.textColor3,
      activeColor: activeColor ?? this.activeColor,
      activeOpacity: activeOpacity ?? this.activeOpacity,
      disabledOpacity: disabledOpacity ?? this.disabledOpacity,
      background: background ?? this.background,
      background2: background2 ?? this.background2,
      background3: background3 ?? this.background3,
      paddingBase: paddingBase ?? this.paddingBase,
      paddingXs: paddingXs ?? this.paddingXs,
      paddingSm: paddingSm ?? this.paddingSm,
      paddingMd: paddingMd ?? this.paddingMd,
      paddingLg: paddingLg ?? this.paddingLg,
      paddingXl: paddingXl ?? this.paddingXl,
      fontBold: fontBold ?? this.fontBold,
      fontSizeXs: fontSizeXs ?? this.fontSizeXs,
      fontSizeSm: fontSizeSm ?? this.fontSizeSm,
      fontSizeMd: fontSizeMd ?? this.fontSizeMd,
      fontSizeLg: fontSizeLg ?? this.fontSizeLg,
      lineHeightXs: lineHeightXs ?? this.lineHeightXs,
      lineHeightSm: lineHeightSm ?? this.lineHeightSm,
      lineHeightMd: lineHeightMd ?? this.lineHeightMd,
      lineHeightLg: lineHeightLg ?? this.lineHeightLg,
      baseFont: baseFont ?? this.baseFont,
      priceFont: priceFont ?? this.priceFont,
      durationBase: durationBase ?? this.durationBase,
      durationFast: durationFast ?? this.durationFast,
      easeOut: easeOut ?? this.easeOut,
      easeIn: easeIn ?? this.easeIn,
      borderColor: borderColor ?? this.borderColor,
      borderWidth: borderWidth ?? this.borderWidth,
      radiusSm: radiusSm ?? this.radiusSm,
      radiusMd: radiusMd ?? this.radiusMd,
      radiusLg: radiusLg ?? this.radiusLg,
      radiusMax: radiusMax ?? this.radiusMax,
    );
  }

  /// 反序列化
  static VanRootThemeData fromJson(Map<String, dynamic> json) {
    return VanRootThemeData.raw(
      black: VanCss(json[kVanBlack.key]),
      white: VanCss(json[kVanWhite.key]),
      gray1: VanCss(json[kVanGray1.key]),
      gray2: VanCss(json[kVanGray2.key]),
      gray3: VanCss(json[kVanGray3.key]),
      gray4: VanCss(json[kVanGray4.key]),
      gray5: VanCss(json[kVanGray5.key]),
      gray6: VanCss(json[kVanGray6.key]),
      gray7: VanCss(json[kVanGray7.key]),
      gray8: VanCss(json[kVanGray8.key]),
      red: VanCss(json[kVanRed.key]),
      blue: VanCss(json[kVanBlue.key]),
      orange: VanCss(json[kVanOrange.key]),
      orangeDark: VanCss(json[kVanOrangeDark.key]),
      orangeLight: VanCss(json[kVanOrangeLight.key]),
      green: VanCss(json[kVanGreen.key]),
      gradientRed: VanCss(json[kVanGradientRed.key]),
      gradientOrange: VanCss(json[kVanGradientOrange.key]),
      primaryColor: VanCss(json[kVanPrimaryColor.key]),
      successColor: VanCss(json[kVanSuccessColor.key]),
      dangerColor: VanCss(json[kVanDangerColor.key]),
      warningColor: VanCss(json[kVanWarningColor.key]),
      textColor: VanCss(json[kVanTextColor.key]),
      textColor2: VanCss(json[kVanTextColor2.key]),
      textColor3: VanCss(json[kVanTextColor3.key]),
      activeColor: VanCss(json[kVanActiveColor.key]),
      activeOpacity: VanCss(json[kVanActiveOpacity.key]),
      disabledOpacity: VanCss(json[kVanDisabledOpacity.key]),
      background: VanCss(json[kVanBackground.key]),
      background2: VanCss(json[kVanBackground2.key]),
      background3: VanCss(json[kVanBackground3.key]),
      paddingBase: VanCss(json[kVanPaddingBase.key]),
      paddingXs: VanCss(json[kVanPaddingXs.key]),
      paddingSm: VanCss(json[kVanPaddingSm.key]),
      paddingMd: VanCss(json[kVanPaddingMd.key]),
      paddingLg: VanCss(json[kVanPaddingLg.key]),
      paddingXl: VanCss(json[kVanPaddingXl.key]),
      fontBold: VanCss(json[kVanFontBold.key]),
      fontSizeXs: VanCss(json[kVanFontSizeXs.key]),
      fontSizeSm: VanCss(json[kVanFontSizeSm.key]),
      fontSizeMd: VanCss(json[kVanFontSizeMd.key]),
      fontSizeLg: VanCss(json[kVanFontSizeLg.key]),
      lineHeightXs: VanCss(json[kVanLineHeightXs.key]),
      lineHeightSm: VanCss(json[kVanLineHeightSm.key]),
      lineHeightMd: VanCss(json[kVanLineHeightMd.key]),
      lineHeightLg: VanCss(json[kVanLineHeightLg.key]),
      baseFont: VanCss(json[kVanBaseFont.key]),
      priceFont: VanCss(json[kVanPriceFont.key]),
      durationBase: VanCss(json[kVanDurationBase.key]),
      durationFast: VanCss(json[kVanDurationFast.key]),
      easeOut: VanCss(json[kVanEaseOut.key]),
      easeIn: VanCss(json[kVanEaseIn.key]),
      borderColor: VanCss(json[kVanBorderColor.key]),
      borderWidth: VanCss(json[kVanBorderWidth.key]),
      radiusSm: VanCss(json[kVanRadiusSm.key]),
      radiusMd: VanCss(json[kVanRadiusMd.key]),
      radiusLg: VanCss(json[kVanRadiusLg.key]),
      radiusMax: VanCss(json[kVanRadiusMax.key]),
    );
  }

  static dynamic get<T>(BuildContext context, {required VanCssKey key, T? defaultValue}) {
    final VanRootThemeData rootTheme = VanRootThemeData.of(context);
    if (kVanBlack == key) return rootTheme.black.get(context);
    if (kVanWhite == key) return rootTheme.white.get(context);
    if (kVanGray1 == key) return rootTheme.gray1.get(context);
    if (kVanGray2 == key) return rootTheme.gray2.get(context);
    if (kVanGray3 == key) return rootTheme.gray3.get(context);
    if (kVanGray4 == key) return rootTheme.gray4.get(context);
    if (kVanGray5 == key) return rootTheme.gray5.get(context);
    if (kVanGray6 == key) return rootTheme.gray6.get(context);
    if (kVanGray7 == key) return rootTheme.gray7.get(context);
    if (kVanGray8 == key) return rootTheme.gray8.get(context);
    if (kVanRed == key) return rootTheme.red.get(context);
    if (kVanBlue == key) return rootTheme.blue.get(context);
    if (kVanOrange == key) return rootTheme.orange.get(context);
    if (kVanOrangeDark == key) return rootTheme.orangeDark.get(context);
    if (kVanOrangeLight == key) return rootTheme.orangeLight.get(context);
    if (kVanGreen == key) return rootTheme.green.get(context);
    if (kVanGradientRed == key) return rootTheme.gradientRed.get(context);
    if (kVanGradientOrange == key) return rootTheme.gradientOrange.get(context);
    if (kVanPrimaryColor == key) return rootTheme.primaryColor.get(context);
    if (kVanSuccessColor == key) return rootTheme.successColor.get(context);
    if (kVanDangerColor == key) return rootTheme.dangerColor.get(context);
    if (kVanWarningColor == key) return rootTheme.warningColor.get(context);
    if (kVanTextColor == key) return rootTheme.textColor.get(context);
    if (kVanTextColor2 == key) return rootTheme.textColor2.get(context);
    if (kVanTextColor3 == key) return rootTheme.textColor3.get(context);
    if (kVanActiveColor == key) return rootTheme.activeColor.get(context);
    if (kVanActiveOpacity == key) return rootTheme.activeOpacity.get(context);
    if (kVanDisabledOpacity == key) return rootTheme.disabledOpacity.get(context);
    if (kVanBackground == key) return rootTheme.background.get(context);
    if (kVanBackground2 == key) return rootTheme.background2.get(context);
    if (kVanBackground3 == key) return rootTheme.background3.get(context);
    if (kVanPaddingBase == key) return rootTheme.paddingBase.get(context);
    if (kVanPaddingXs == key) return rootTheme.paddingXs.get(context);
    if (kVanPaddingSm == key) return rootTheme.paddingSm.get(context);
    if (kVanPaddingMd == key) return rootTheme.paddingMd.get(context);
    if (kVanPaddingLg == key) return rootTheme.paddingLg.get(context);
    if (kVanPaddingXl == key) return rootTheme.paddingXl.get(context);
    if (kVanFontBold == key) return rootTheme.fontBold.get(context);
    if (kVanFontSizeXs == key) return rootTheme.fontSizeXs.get(context);
    if (kVanFontSizeSm == key) return rootTheme.fontSizeSm.get(context);
    if (kVanFontSizeMd == key) return rootTheme.fontSizeMd.get(context);
    if (kVanFontSizeLg == key) return rootTheme.fontSizeLg.get(context);
    if (kVanLineHeightXs == key) return rootTheme.lineHeightXs.get(context);
    if (kVanLineHeightSm == key) return rootTheme.lineHeightSm.get(context);
    if (kVanLineHeightMd == key) return rootTheme.lineHeightMd.get(context);
    if (kVanLineHeightLg == key) return rootTheme.lineHeightLg.get(context);
    if (kVanBaseFont == key) return rootTheme.baseFont.get(context);
    if (kVanPriceFont == key) return rootTheme.priceFont.get(context);
    if (kVanDurationBase == key) return rootTheme.durationBase.get(context);
    if (kVanDurationFast == key) return rootTheme.durationFast.get(context);
    if (kVanEaseOut == key) return rootTheme.easeOut.get(context);
    if (kVanEaseIn == key) return rootTheme.easeIn.get(context);
    if (kVanBorderColor == key) return rootTheme.borderColor.get(context);
    if (kVanBorderWidth == key) return rootTheme.borderWidth.get(context);
    if (kVanRadiusSm == key) return rootTheme.radiusSm.get(context);
    if (kVanRadiusMd == key) return rootTheme.radiusMd.get(context);
    if (kVanRadiusLg == key) return rootTheme.radiusLg.get(context);
    if (kVanRadiusMax == key) return rootTheme.radiusMax.get(context);
    return null;
  }

  static VanRootThemeData of(BuildContext context) => VanTheme.of(context).rootTheme;
}
